package cn.le.theme;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 项目名  spring-boot
 * Created by lansp
 * Created at 2018/6/1
 * 描述:
 */
@Configuration
public class HemeConfig {

	@Bean
	public Queue queueMessageA(){
		return new Queue("topic.A");
	}

	@Bean
	public Queue queueMessageB(){
		return new Queue("topic.B");
	}

	//配置一个交换机 direct
	@Bean
	public TopicExchange exchange(){
		return new TopicExchange("topicExchange");
	}

	//绑定队列到交换机上,路由模式,需要完成匹配topic.message,才能接收
	@Bean
	public Binding bindingTopicExchangeA(TopicExchange exchange){
		return BindingBuilder.bind(queueMessageA()).to(exchange).with(" .message");
	}
	@Bean
	public Binding bindingTopicExchangeB(TopicExchange exchange){
		return BindingBuilder.bind(queueMessageB()).to(exchange).with("topic.#");
	}


}
